var timeout     = 500;
var closetimer  = 0;
var menuitem  = 0;
var cssover = 0;
// Aktueller Layer anzeigen
function mopen(id) {    
	// Closetimer abbrechen
	mcancelclosetime();

	// Vorherhiger Layer schliessen
	if(menuitem) menuitem.style.visibility = 'hidden';
	if(cssover) cssover.className = '';

	// Neuen Layer anzeigen
	cssover = document.getElementById(id+"kat");
	cssover.className = 'overmenu';
	menuitem = document.getElementById(id);
	menuitem.style.visibility = 'visible';
}
// Angezeigten Layer "schliessen"
function mclose() {
	if(menuitem) menuitem.style.visibility = 'hidden';
    if (cssover) cssover.className = '';
}

// Closetimer starten
function mclosetime() {
	closetimer = window.setTimeout(mclose, timeout);
}

// Closetimer abbrechen
function mcancelclosetime() {
	if(closetimer) {
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// Bei wegklicken den Layer schliessen
document.onclick = mclose; 
